package com.app.ytong.bean;


import android.text.TextUtils;

import com.alibaba.fastjson.annotation.JSONField;

import java.util.ArrayList;
import java.util.List;

public class KWListBean extends BaseListBean {



    private ArrayList<KWListData> list = new ArrayList<KWListData>();

    public ArrayList<KWListData> getList() {
        return list;
    }

    public void setList(ArrayList<KWListData> list) {
        this.list = list;
    }

    @JSONField(serialize = false)
    public void addListBean(KWListBean listbean) {
        if (listbean == null)
            return;
        if (this.getCurrentPage() == INIT_PAGE) {
            setList(listbean.getList());
        } else {
            if (list == null)
                list = new ArrayList<KWListData>();
            list.addAll(listbean.getList());
        }
        setListBeanData(listbean);
    }

    public List<String> getAllNameList(){
        List<String> nameList = new ArrayList<>();
        for(KWListData data : list){
            nameList.add(data.getWna());
        }
        return nameList;
    }

    public String[] getAllNames(){
        List<String> nameList = getAllNameList();
        if(nameList == null || nameList.size()== 0){
            return null;
        }
        String[] arr = nameList.toArray(new String[nameList.size()]);
        return arr;
    }

    public int getPisitionByName(String name){
        if(TextUtils.isEmpty(name)) return 0;
        for (int i =0 ;i<list.size();i++){
            if(list.get(i).getWna().contains(name)){
                return i;
            }
        }
        return 0;
    }

}
